#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t, x, y;
	cin>>t;
	while(t--)
	{
		cin>>x>>y;
		if(x == y)
			cout<<0<<endl;
		else if(x > y)
		{
			if(x%2 != y%2)
				cout<<2<<endl;
			else
				cout<<1<<endl;
		}
		else if(x < y)
		{
			if(x%2 != y%2)
				cout<<1<<endl;
			else
				cout<<2<<endl;
		}
	}
	return 0;
}

